<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="./template/layout.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
	<ui:define name="conteudo">
		<div style="margin: 40px 0 0 0;">
			<h:form enctype="multipart/form-data">
				<p:fieldset legend="Biblioteca Virtual IDEZ - Cadastro de livro" style="margin: 10px 150px 0 150px;">
					<p:panelGrid id="CadLivro" columns="2" style="margin: 0 10px 0 120px;">

						<h:outputText value="Livro: " />
						<p:inputText value="#{livroBEAN.livro.nome}" />

						<h:outputText value="Autor: " />
						<h:selectOneMenu value="#{livroBEAN.livro.autores.id}" id="autor" required="true">
	    					<f:selectItems value="#{livroBEAN.autores}" var="v" itemLabel="#{v.nome}" itemValue="#{v.id}"></f:selectItems>
						</h:selectOneMenu>
						
						<h:outputText value="Categoria: " />
						<h:selectOneMenu value="#{livroBEAN.livro.categorias.id}" id="categoria" required="true">
	    					<f:selectItems value="#{livroBEAN.categorias}" var="v" itemLabel="#{v.descricao}" itemValue="#{v.id}"></f:selectItems>
						</h:selectOneMenu>

						<h:outputText value="Ano publicação: " />
						<p:calendar value="#{livroBEAN.livro.ano}" id="cal"
							showButtonPanel="true" />

						<h:outputText value="Páginas: " />
						<p:inputText value="#{livroBEAN.livro.paginas}" />

						<h:outputText value="ISBN: " />
						<p:inputText value="#{livroBEAN.livro.ibsb}" />

						<h:outputText value="Idioma: " />
						<p:inputText value="#{livroBEAN.livro.idioma}" />

						<h:outputText value="Editora: " />
						<h:selectOneMenu value="#{livroBEAN.livro.editora.id}" id="editora" required="true">
	    					<f:selectItems value="#{livroBEAN.editoras}" var="v" itemLabel="#{v.nome}" itemValue="#{v.id}"></f:selectItems>
						</h:selectOneMenu>
						
						<h:outputText value="Foto: " />
						<p:fileUpload value="#{livroBEAN.file}"	mode="simple" />
						<f:facet name="footer">
							<p:commandButton value="Cadastrar" icon="ui-icon-star"
								actionListener="#{livroBEAN.cadastrarLivro()}" ajax="false"
								rendered="#{livroBEAN.btnCadastrar}" />
							<p:commandButton value="Salvar" icon="ui-icon-disk"
								action="#{livroBEAN.salvarLivro()}" ajax="false"
								rendered="#{livroBEAN.btnSalvar}" />
							<p:commandButton value="Limpar" icon="ui-icon-eraser" action="#" />
							<p:commandButton value="Cancelar" icon="ui-icon-eraser"
								action="#{livroBEAN.cancelar()}" ajax="false" />

						</f:facet>
					</p:panelGrid>
				</p:fieldset>
			</h:form>
			<h:form>			
			<p:growl id="msg" globalOnly="true" showDetail="true"/>			
		</h:form>
		</div>
	</ui:define>
</ui:composition>